
import pymysql

host="localhost"
port=3306
user="root"
password="root"
database="finance"
class DButils:
# 专门处理增，删，改
    def update(self,sql,param):
        con = pymysql.connect(host=host,port=port,user=user,password=password,database=database)
        cursor =  con.cursor()
        cursor.execute(sql,param)
        con.commit()
        cursor.close()
        con.close()

    # 专门处理查询
    def  select(self,sql,param):

        con = pymysql.connect(host=host,port=port,user=user,password=password,database=database)
        cursor =  con.cursor()
        cursor.execute(sql,param)
        data =  cursor.fetchall()
        con.commit()
        cursor.close()
        con.close()
        return data


# if __name__=="__main__":
#     sql = "select * from user where username  = %s"
#     param = ["lisi"]
#     print(type(select(sql,param)))


